﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace STHPMS1.Web.W_View.Survey
{
    public partial class Down : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             string serverPath="";
             if (Request.QueryString["type"] == null)
            {
                serverPath = Server.MapPath("/App_Data/Upload/检测数据模板.rar");
            }
            else if (Request.QueryString["type"] == "fwd")
            {
                serverPath = Server.MapPath("/App_Data/Upload/fwd.rar");
            }
             else if (Request.QueryString["type"] == "road")
             {
                 serverPath = Server.MapPath("/App_Data/Upload/路线模板.rar");
             }
             else if (Request.QueryString["type"] == "zz")
             {
                 serverPath = Server.MapPath("/App_Data/Upload/轴载模板.rar");
             }
             else if (Request.QueryString["type"] == "jtl")
             {
                 serverPath = Server.MapPath("/App_Data/Upload/交通量模板.rar");
             }
             else if (Request.QueryString["type"] == "lmjg")
             {
                 serverPath = Server.MapPath("/App_Data/Upload/路面结构层模板.rar");
             }
             else if (Request.QueryString["type"] == "hfbz")
             {
                 serverPath = Server.MapPath("/App_Data/Upload/划分标准模板.rar");
             }
             else if (Request.QueryString["type"] == "gzw")
             {
                 serverPath = Server.MapPath("/App_Data/Upload/构造物模板.rar");
             }
            Stream fs = new FileStream(serverPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            FileInfo fi = new FileInfo(serverPath);
            Response.Clear();
           // string encodefileName = System.Web.HttpUtility.UrlEncode(fi.Name, System.Text.Encoding.Default); //通过使用HttpUtility.UrlEncode()来对原始文件名进行编码,以解决文件名乱码
            Response.AppendHeader("content-disposition", "attachment;filename=" + fi.Name);//附件下载
            Response.ContentType = "image/jpg";
            Response.WriteFile(serverPath);
            Response.End();
        }
    }
}